class Solution3 {
    public String multiply(String num1, String num2) {
        if(num1.charAt(0) == '0' || num2.charAt(0) == '0'){
            return "0";
        }
        int len1 = num1.length();
        int len2 = num2.length();
        int[] arr = new int[len1 + len2 - 1];
        for(int i = 0; i < len1; i++){
            for(int j = 0; j < len2; j++){
                arr[i + j] += (num1.charAt(i) - '0') * (num2.charAt(j) - '0');
            }
        }
        StringBuilder s = new StringBuilder();
        int t = 0;
        for(int i = (len1 + len2 - 1) - 1; i >= 0; i--){
            t += arr[i];
            s.append(t % 10);
            t /= 10;
        }
        if(t > 0){
            s.append(t);
        }
        s.reverse();
        return s.toString();
    }
}
